<?php
/**
 * User: @lixu
 * Date: 2019-04-16
 * Time: 18:43
 */

namespace Biz\module\Classes\adm;

use Biz\pockets\excel\DownExcel;

class NewComerExcel
{
    public static function downList($list)
    {
        $header = ['商家ID', '商家名称', '商品ID', '商品名称', '活动开始时间', '活动结束时间', '活动价格-最低', '实时库存', '商品状态'];


        $letter = range('A', 'I');

        $excelObj = new DownExcel();
        $excelObj->setFileName('新人专享活动');
        $excelObj->setSheetTitle('新人专享活动');
        //设置列宽
        $widths = ['A' => 15, 'B' => 30, 'C' => 15, 'D' => 30, 'E' => 20, 'F' => 20, 'G' => 15, 'H' => 10, 'I' => 10];
        $excelObj->setWidth($widths);
        //默认单元格居中
        $excelObj->setDefaultStyleAlignment();
        foreach ($header as $key => $value) {
            //设置字体
            $excelObj->setFrontName($letter[$key]);
            //设置大小
            $excelObj->setFrontSize($letter[$key]);
        }

        $excelObj->create($list, $header);
        return true;
    }
}